package com.taxi.config;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author: aniu
 * @Date: 2023/10/12
 * @ClassName: AlipayConfig
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@Configuration
@ConfigurationProperties(prefix = "alipay")
@Data
public class AlipayConfig {
    private String appId;
    private String appPrivateKey;
    private String publicKey;
    private String returnUrl;
    private String frontReturnUrl;
    private String notifyUrl;

    @PostConstruct
    public void init(){
        Config config=new Config();
        //基础配置
        config.protocol="https";
        config.gatewayHost="openapi-sandbox.dl.alipaydev.com";
        config.signType="RSA2";

        //业务配置
        config.appId=this.appId;
        config.merchantPrivateKey=this.appPrivateKey;
        config.alipayPublicKey=this.publicKey;
        config.notifyUrl=this.notifyUrl;
        Factory.setOptions(config);
        System.out.println("支付宝配置初始化完成");
    }
}
